package correct.day15;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Test22 {
    public static int n, m;
    public static Map<Integer, Integer> hash = new HashMap<>();

    // 判断每组人数最多为 x 时，是否能分为 m 组
    public static boolean check(int x) {
        int g = 0;
        for (int a : hash.values()) {
            g += a / x + (a % x == 0 ? 0 : 1);
        }

        return g <= m;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        int hmax = 0; // 所有声部的最⼤值

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            hash.put(x, hash.getOrDefault(x, 0) + 1);
            hmax = Math.max(hmax, hash.get(x));
        }

        if (hash.size() > m) {
            System.out.println(-1);
        } else {
            for (int i = 0; i < hmax; i++) {
                if (check(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }
    }
}
